package com.library.vo;

import lombok.Data;

public class BaseResult<T> {

    private String stateCode;
    private String msg;
    private T data;

    public static final String stateCode_success = "200";
    public static final String stateCode_fail = "-1";

    public static BaseResult<Boolean> success(){
        BaseResult<Boolean> baseResult = new BaseResult();
        baseResult.stateCode = stateCode_success;
        baseResult.setData(true);
        baseResult.setMsg("成功");
        return baseResult;
    }

    public static BaseResult successWithData(Object Data){
        BaseResult baseResult = new BaseResult();
        baseResult.stateCode = stateCode_success;
        baseResult.setData(Data);
        baseResult.setMsg("成功");
        return baseResult;
    }

    public static BaseResult<Object> fail(String msg){
        BaseResult baseResult = new BaseResult();
        baseResult.stateCode = stateCode_fail;
        baseResult.setData(false);
        baseResult.setMsg(msg);
        return baseResult;
    }


    public String getStateCode() {
        return stateCode;
    }

    public void setStateCode(String stateCode) {
        this.stateCode = stateCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static String getStateCode_success() {
        return stateCode_success;
    }

    public static String getStateCode_fail() {
        return stateCode_fail;
    }
}
